package z;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class ch6_3 extends JFrame implements ActionListener {
    JPanel p;
    JLabel l;
    JTextField in,out;
    public ch6_3() {
        l = new JLabel("请输入您的名字");
        in=new JTextField(8);
        out=new JTextField(20);
        p=new JPanel();
        p.add(l);
        p.add(in);
        p.add(out);
        Container c=this.getContentPane();
        c.add(p);
        in.addActionListener(this);
    }

    public void actionPerformed(ActionEvent e) {
        out.setText(in.getText()+"欢迎光临！");
    }
    public static void main(String[] args) {
        JFrame f=new ch6_3();
        f.setVisible(true);
        f.setSize(300,300);
    }
}
